package com.umeox.watch.worshiplearn.adapter

import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
import com.umeox.moto.watch.themes.widget.ImageView
import com.umeox.moto.watch.themes.widget.TextView
import com.umeox.watch.worshiplearn.R
import com.umeox.watch.worshiplearn.model.LmanItem

/**
 * Created by Rambo 2022/9/10
 * Describe:
 */
class LmanViewPagerAdapter(private val data: List<LmanItem>) :
    RecyclerView.Adapter<LmanViewPagerAdapter.ViewPagerHolder?>() {

    override fun onCreateViewHolder(
        parent: ViewGroup,
        viewType: Int
    ): LmanViewPagerAdapter.ViewPagerHolder {
                return ViewPagerHolder(
            LayoutInflater.from(parent.context).inflate(R.layout.iman_item_pager, parent, false)
        )
    }

    override fun onBindViewHolder(holder: LmanViewPagerAdapter.ViewPagerHolder, position: Int) {
        holder.mImageView.setImageResource(data[position].resId)
        holder.mNameTv.text = data[position].name
    }

    override fun getItemCount(): Int {
        return data.size
    }


    inner class ViewPagerHolder(itemView: View) :
        RecyclerView.ViewHolder(itemView) {
        var mImageView: ImageView
        var mNameTv: TextView

        init {
            mImageView = itemView.findViewById(R.id.iv)
            mNameTv = itemView.findViewById(R.id.tv_name)
        }
    }
}
